package com.yupi.yuaiagent.agent;

import com.yupi.yuaiagent.advisor.MyLoggerAdvisor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * 鱼皮的 AI 超级智能体（拥有自主规划能力，可以直接使用）
 */
@Component
public class YuManus extends ToolCallAgent {

    public YuManus(ToolCallback[] allTools, ChatModel dashscopeChatModel) {
        super(allTools);
        this.setName("yuManus");
//        String SYSTEM_PROMPT = "You are YuManus, an all-capable AI assistant, aimed at solving any task presented by the user.\n" +
//                "You have various tools at your disposal that you can call upon to efficiently complete complex requests.";
        String SYSTEM_PROMPT = "你是 YuManus，一个全能的人工智能助手，旨在解决用户提出的任何任务。\\n" + "您可以使用各种工具来高效完成复杂的请求。";
        this.setSystemPrompt(SYSTEM_PROMPT);
//        String NEXT_STEP_PROMPT = "Based on user needs, proactively select the most appropriate tool or combination of tools.\n" +
//                "For complex tasks, you can break down the problem and use different tools step by step to solve it.\n" +
//                "After using each tool, clearly explain the execution results and suggest the next steps.\n" +
//                "If you want to stop the interaction at any point, use the `terminate` tool/function call.";
        String NEXT_STEP_PROMPT = "根据用户需求，主动选择最合适的工具或工具组合。对于复杂的任务，可以分解问题，使用不同的工具一步步解决。" +
                "使用每个工具后，清楚说明执行结果并建议下一步行动。如果你想在任何时候停止交互或者如果用户没有明显的需求时，使用“terminate”tool函数调用。";
        this.setNextStepPrompt(NEXT_STEP_PROMPT);
        this.setMaxSteps(10);
        // 初始化 AI 对话客户端
        ChatClient chatClient = ChatClient.builder(dashscopeChatModel)
                .defaultAdvisors(new MyLoggerAdvisor())
                .build();
        this.setChatClient(chatClient);
    }
}